[wrangler] Preserve serialized error details in castErrorCause - #14906
Open
exKAZUu wants to merge 5 commits into
Open
[wrangler] Preserve serialized error details in castErrorCause#14906exKAZUu wants to merge 5 commits into
exKAZUu wants to merge 5 commits into
Conversation
Errors reported by the ProxyWorker cross a JSON channel and arrive as SerializedError plain objects. castErrorCause wrapped them in a message-less new Error(), so the fatal log from emitErrorEvent was an empty '✘ [ERROR]' with no indication of the actual failure (see cloudflare#14641, e.g. transient 'Network connection lost.' keep-alive races killing the whole dev server with an empty error). Rehydrate the serialized message/name/stack instead.
🦋 Changeset detectedLatest commit: a679436 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
workers-devprod
requested review from
a team and
emily-shen
and removed request for
a team
July 29, 2026 12:47
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
@cloudflare/autoconfig
@cloudflare/config
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
…ProxyWorkerMessage Verifies the emitted error event carries the original message/stack after crossing the JSON channel, guarding against the empty '✘ [ERROR]' regression from cloudflare#14641.
Review findings: tighten isSerializedError to the exact shape produced by serialiseError/ProxyWorker (no extra keys) so arbitrary message-bearing objects keep the wrap-as-cause behavior; skip the own 'cause: undefined' property that polluted util.format debug logs; recursively rehydrate serialized cause chains so instanceof-Error cause classifiers work across the JSON channel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the diagnosability problem reported in #14641 (the underlying keep-alive race itself is tracked separately in that issue).
Errors reported by the ProxyWorker cross a JSON channel, so they always arrive in
ProxyController.onProxyWorkerMessageasSerializedErrorplain objects, neverErrorinstances.castErrorCause()wrapped them in a message-lessnew Error(), keeping the original report only as an unprinted.cause— so when a transient failure (e.g.Network connection lost.from the kj 5s keep-alive race described in #14641) was treated as fatal,wrangler devexited with an empty✘ [ERROR]log and no indication of the actual failure, which reportedly cost multiple users many hours of debugging.This change makes
castErrorCause()rehydrateSerializedError-shaped causes into a realError, preserving the originalmessage,nameandstack(and keeping the serialized nestedcause). Behavior forErrorinstances and other non-Error causes is unchanged.castErrorCause()covering Error passthrough, rehydration of a JSON-roundtrippedserialiseError()payload (message/name/stack preserved), nested cause preservation, and unchanged wrapping of other non-Error values. Plus a ProxyController integration test dispatching a serialized{ type: "error" }ProxyWorker message throughonProxyWorkerMessageand asserting the emitted error event carries the original message/stack (fails without this fix withexpected '' to be 'Network connection lost.').✘ [ERROR]logs now contain the actual error message.